<template>
	<view>
		<web-view :src="videoUrl" class="web-box"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				videoUrl:'',
				qid:'',
				nmn:'',
				sbIp:''
			}
		},
		onLoad(options) {
			this.getTc()
			uni.showLoading({
				title: '加载中'
			});
			const sbIp = options.ip
			const result = sbIp.replace(/^(.*?):.*$/, (match, group1) => group1 || sbIp);
			this.sbIp = result
			this.videoUrl = 'http://'+result+':5000'
			setTimeout(()=>{
				this.align(options.pid)
				uni.hideLoading();
			},1500)
			console.log(this.videoUrl)
		},
		onShow() {
			
		},
		onHide() {
			
		},
		methods: {
			async getTc(){
				let res = await this.http("get","/tc/tcOperate/getTcqueueList")
				console.log(res)
				if(res.code==200){
					res.data.forEach(item=>{
						if(item.status=='1'){
							this.qid = item.id
						}
					})
					let res1 = await this.http("get","/tc/tcOperate/tcQueueStudentList",{
						pageNum: 1,
						pageSize: 1000,
						queueid: this.qid
					})
					this.nmn = res1.total
				}
			},
			align(pid){
				let data = {
					ope:'C',
					pid:pid,
					nmn:this.nmn,
					qid:this.qid
				}
				uni.request({
				    url: 'http://'+this.sbIp+':8000', //仅为示例，并非真实接口地址。
				    data: data,
					header:{
						'content-type':'application/x-www-form-urlencoded'
					},
					method:'post',
				    success: (res) => {
				        console.log(res.data);
				    }
				});
			}
		}
	}
</script>

<style lang="less">
	.web-box{
		width: 100%;
	}
</style>